package agenceVoyageVirtuel.client.viewer;

import agenceVoyageVirtuel.client.beans.PackData;
import agenceVoyageVirtuel.client.beans.VoyageData;
import agenceVoyageVirtuel.client.control.ZoneDeTravail;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DisclosurePanel;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.datepicker.client.DatePicker;

public class DetailPackViewer extends Composite {

	private final ZoneDeTravail zoneDeTravail;
	private VerticalPanel verticalPanel;
	private Button button;

	public DetailPackViewer(ZoneDeTravail zoneDeTravail, PackData pack) {
		this.zoneDeTravail = zoneDeTravail;
		verticalPanel = new VerticalPanel();
		
		Label lblTitle = new Label("Pack : "+pack.getLibPack());
		verticalPanel.add(lblTitle);

		DatePicker datePicker = new DatePicker();
		DisclosurePanel disclosurePanel = new DisclosurePanel("Date du debut de vos vacances : ");
		disclosurePanel.add(datePicker);
		verticalPanel.add(disclosurePanel);
		HorizontalPanel flowPanel = new HorizontalPanel();
		int tarifTotal=0;
		for(VoyageData voyageData: pack.getVoyages()){
			tarifTotal+= voyageData.getTarifQuotidien();
			flowPanel.add(new DetailVoyageViewer(voyageData));
		}
		verticalPanel.add(flowPanel);
		Label lblPrix = new Label("Prix Total du pack: "+tarifTotal);
		verticalPanel.add(lblPrix);
		button = new Button("Ajouter au panier");
		if(zoneDeTravail.isLogged()){
			verticalPanel.add(button);
		}
		initWidget(verticalPanel);
		
	}

	public void changeToLogged() {
		verticalPanel.add(button);
	}

	public void changeToNotLogged() {
		verticalPanel.remove(button);
	}

}
